home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 8 / QRZ Ham Radio Callsign Database - Volume 8.iso / pc / files / dsp / 96000tar.z / 96000tar / 96000 / julia.asm < prev    next >
Assembly Source File  |  1992-04-28  |  3KB  |  85 lines

  1. ; This program, originally available on the Motorola DSP bulletin board
  2. ; is provided under a DISCLAIMER OF WARRANTY available from Motorola DSP
  3. ; Operation, 6501 William Cannon Drive West, Austin, Texas  78735-8598.
  4. ;
  5. ; This program generates the Julia Set, found by Gaston Julia in
  6. ; early twentieth century.  It outputs N * N integers which
  7. ; can be mapped to color tables for display.  The points
  8. ; with integer value equal to "MAX" are in the Julia Set.
  9. ; The quadratic functions used : f(z) = z*z + c, where |c| < 2
  10. ; Example Seed values  :  c = c1 + c2
  11. ; (1) -1.0
  12. ; (2) 0.3 - j0.4
  13. ; (3) 0.360284 + j0.100376
  14. ; (4) -0.1 + j0.8
  15. ; Motorola DSP Applications
  16. ; Last Update : 8-3-90
  17. ; d0,d1 : store intermediate results
  18. ; d2 : intermediate result, and 4.0
  19. ; d3 : counter
  20. ; d4 : y0, starts at 2.0
  21. ; d5 : c2
  22. ; d6 : x0, starts at -2.0
  23. ; d7 : 1/50, or 0.02
  24. ; d8 : c1
  25. ; d9 : not used
  26.  
  27. main   equ $100
  28. coef   equ $0
  29. output equ $100
  30. N      equ 200
  31. MAX    equ 20
  32.  
  33.   org x:coef
  34.       dc  2.0
  35.       dc  4.0
  36.  
  37.   org y:coef
  38.       dc  MAX
  39.  
  40.   org p:main
  41.   move #coef+2,r0
  42.   move #coef+3,r4                    ; temporary storage for x,y,x0,y0
  43.   move #coef,r2
  44.   move #output,r5
  45.   clr  d3  #-2.0,d6.s                ; x0
  46.   move #0.8,d5.s
  47.   move #0.02,d7.s                    ; 1/50
  48.   move #2.0,d4.s                     ; y0
  49.   fadd.s d7,d6          #-0.1,d8.s   ; update x0, c1
  50.   fsub.s d7,d4                       ; update y0
  51.   move d6.s,x:(r0) d4.s,y:
  52.   move d6.s,x:(r4) d4.s,y:           ; initiliazation
  53.  
  54.   do #N,_mloop
  55.   do #N,_nloop
  56. _count
  57.   move   x:(r4),d6.s y:,d4.s
  58.   fmpy.s d6,d6,d1    d8.s,d0.s                            ; x*x, c1
  59.   fmpy   d4,d4,d0    fadd.s d0,d1                         ; y*y, x*x+c1
  60.   fmpy   d4,d6,d0    fsub.s d0,d1  d4.s,d2.s x:(r2)+,d4.s ; x*y, x1, 2
  61.   fmpy.s d0,d4,d0    d1.s,d4.s     d1.s,x:(r4)            ; 2*x*y, x1
  62.   fmpy   d4,d4,d1    fadd.s d5,d0  d2.s,d4.s x:(r2)-,d2.s ; x1*x1, y1
  63.   fmpy.s d0,d0,d0    d0.s,y:(r4)                          ; y1*y1
  64.   fadd.s d1,d0                                            ; z
  65.   fcmp   d0,d2       y:(r2),d2.l                          ; 4.0-z, MAX
  66.   fjmi   _save                                     ; check for out of bound
  67.   inc    d3                                               ; counter++
  68.   cmp   d2,d3                                             ; MAX-counter
  69.   jne   _count
  70.  
  71. _save
  72.   move   x:(r0),d2.s y:,d4.s                              ; update y0
  73.   fsub.s d7,d4       d3.l,y:(r5)+                         ; output
  74.   clr    d3          d4.s,y:(r0)                          ; reset counter
  75.   move   d2.s,x:(r4) d4.s,y:
  76. _nloop
  77.  
  78.  move    x:(r0),d6.s
  79.  fadd.s  d7,d6       x:(r2),d4.s                          ; update x0
  80.  fsub.s  d7,d4       d6.s,x:(r0)                          ; update y0
  81.  move    d6.s,x:(r4) d4.s,y:
  82.  move    d4.s,y:(r0)
  83. _mloop
  84.  
  85.